//
//  HNSH_ReportViewController.m
//  HNSH_SingleProject
//
//  Created by 李宇廷 on 2023/2/17.
//

#import "HNSH_ReportViewController.h"

@interface HNSH_ReportViewController ()
/** */
@property (nonatomic, strong)UIView * bgView;
/** */
@property (nonatomic, strong)UILabel * nameLabel;
/** */
@property (nonatomic, strong)UITextField * nameTextField;
/** */
@property (nonatomic, strong)UILabel * reasonLabel;
/** */
@property (nonatomic, strong)UIView * reasonView;
/** */
@property (nonatomic, strong)UITextView * reasonTextView;
/** */
@property (nonatomic, strong)UIView * segView;
/** */
@property (nonatomic, strong)UILabel * titleLabel;
/** 举报按钮 */
@property (nonatomic, strong)UIButton * reportBtn;

@end

@implementation HNSH_ReportViewController

//MARK: Cycle Methods
- (void)viewDidLoad{
    [super viewDidLoad];
        
    [self showNavTitle:@"举报" showLeftItem:YES];
    [self addAllViews];
    [self addAllLayout];
}

- (void)addAllViews{
    [self.view addSubview:self.bgView];
    [self.bgView addSubview:self.nameLabel];
    [self.bgView addSubview:self.nameTextField];
    [self.bgView addSubview:self.reasonLabel];
    [self.bgView addSubview:self.reasonView];
    [self.reasonView addSubview:self.reasonTextView];
    [self.view addSubview:self.reportBtn];
}

- (void)addAllLayout{
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.right.mas_equalTo(0);
        make.top.mas_equalTo(kNavBarAndStatusBarHeight + 8);
        make.height.mas_equalTo(371);
    }];
    [self.nameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(28);
        make.right.mas_equalTo(-28);
        make.height.mas_equalTo(22);
        make.top.mas_equalTo(16);
    }];
    [self.nameTextField mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.nameLabel);
        make.right.mas_equalTo(-28);
        make.top.mas_equalTo(self.nameLabel.mas_bottom).offset(8);
        make.height.mas_equalTo(32);
    }];
    [self.reasonLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.nameTextField.mas_bottom).offset(11);
        make.left.right.height.mas_equalTo(self.nameLabel);
    }];
    [self.reasonView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(self.reasonLabel.mas_bottom).offset(8);
        make.left.right.mas_equalTo(self.nameLabel);
        make.height.mas_equalTo(227);
    }];
    [self.reasonTextView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(13);
        make.left.mas_equalTo(14);
        make.right.mas_equalTo(-14);
        make.bottom.mas_equalTo(-13);
    }];
}

//MARK: Custom Methods
- (void)reportBtnAction{
    [HNSH_ChatNetServer requestRongCloudFriendshipReportWithRcUserId:self.rcUserId reason:self.reasonTextView.text success:^(ST_BaseNetModel * _Nullable responseObject) {
        if (responseObject.code == 0) {
            [kSTWindow makeToast:@"举报成功"];
            [self.navigationController popViewControllerAnimated:YES];
        }
    } Failure:^(NSError * _Nullable error) {
        
    }];
}

//MARK: Getter Methods
- (UIView *)bgView{
    if (!_bgView) {
        _bgView = [UIView new];
        _bgView.backgroundColor = [UIColor appWhiteLabelColor];
    }
    return _bgView;
}

- (UILabel *)nameLabel{
    if (!_nameLabel) {
        _nameLabel = [UILabel new];
        _nameLabel.font = [UIFont systemFontOfSize:16];
        _nameLabel.textColor = [UIColor appBlack333LabelColor];
        _nameLabel.text = @"被举报用户";
    }
    return _nameLabel;
}

- (UITextField *)nameTextField{
    if (!_nameTextField) {
        _nameTextField = [UITextField new];
        _nameTextField.font = [UIFont systemFontOfSize:16];
        _nameTextField.layer.cornerRadius = 4;
        _nameTextField.layer.masksToBounds = YES;
        _nameTextField.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
        _nameTextField.layer.borderWidth = 1;
        _nameTextField.placeholder = @"请输入被举报用户姓名";
        _nameTextField.userInteractionEnabled = NO;
        _nameTextField.text = self.name;

        UIView * leftView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 14, 32)];
        _nameTextField.leftView = leftView;
        _nameTextField.leftViewMode = UITextFieldViewModeAlways;
    }
    return _nameTextField;
}

- (UILabel *)reasonLabel{
    if (!_reasonLabel) {
        _reasonLabel = [UILabel new];
        _reasonLabel.font = [UIFont systemFontOfSize:16];
        _reasonLabel.textColor = [UIColor appBlack333LabelColor];
        _reasonLabel.text = @"举报原因";
    }
    return _reasonLabel;
}

- (UIView *)reasonView{
    if (!_reasonView) {
        _reasonView = [UIView new];
        _reasonView.layer.cornerRadius = 4;
        _reasonView.layer.masksToBounds = YES;
        _reasonView.layer.borderColor = [UIColor colorWithHexString:@"#E6E6E6"].CGColor;
        _reasonView.layer.borderWidth = 1;
    }
    return _reasonView;
}

- (UITextView *)reasonTextView{
    if (!_reasonTextView) {
        _reasonTextView = [UITextView new];
        _reasonTextView.font = [UIFont systemFontOfSize:14];
        _reasonTextView.placeholder = @"请填写举报原因，如谩骂，挑衅等等";
    }
    return _reasonTextView;
}

- (UIButton *)reportBtn{
    if (!_reportBtn) {
        _reportBtn = [UIButton new];
        _reportBtn.frame = CGRectMake(28, kScreenHeight - kBottomSafeHeight - 48 - 12, kScreenWidth - 56, 48);
        [_reportBtn setTitle:@"举报" forState:UIControlStateNormal];
        [_reportBtn setTitleColor:[UIColor colorWithHexString:@"#FFFFFF"] forState:UIControlStateNormal];
        _reportBtn.titleLabel.font = [UIFont systemFontOfSize:16];
        _reportBtn.backgroundColor = [UIColor appBlackLabelColor];
        _reportBtn.layer.cornerRadius = 4;
        _reportBtn.layer.masksToBounds = YES;
        [_reportBtn addTarget:self action:@selector(reportBtnAction) forControlEvents:UIControlEventTouchUpInside];
    }
    return _reportBtn;
}

@end
